package com.aishuang.user.config;

import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: ServerConfig
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2024/3/6 14:01
 */
@Configuration
public class ServerConfig implements ApplicationListener<WebServerInitializedEvent> {

    private Integer tomcatport;
    @Override
    public void onApplicationEvent(WebServerInitializedEvent webServerInitializedEvent) {
        tomcatport = webServerInitializedEvent.getWebServer().getPort();
    }

    public Integer getPort() {
        return tomcatport;
    }
}
